<!--
 * @FileDescription 判断框
 * @Author lz
 * @Date 20230131 15:15:55
 * @LastEditors lz
 * @LastEditTime 20230131 15:15:55
-->
<template>
    <div class="contentBoxWp" v-if="state.show">
        <div class="contentBox">
            <div class="content">
                <div class="txt">{{ props.Questions }}</div>
                <div class="correct Btn" @click="choice(1)">确定</div>
                <div class="error Btn" @click="choice(2)">取消</div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'

import { reactive, ref, toRefs, onBeforeMount, onMounted, onBeforeUpdate, onUpdated, onUnmounted, StyleValue, defineProps, defineEmits } from 'vue'
import GameObjectComponent from '@runtime/UnityEngineBridge/GameObjectComponent';
import { ClientMessage } from '@runtime/generate/message/ClientMessage';
import WebSocketComponent from '@runtime/module/WebSocket/WebSocketComponent';
import MessageCode from './MessageCode';
interface Props {
    Questions: any;
    ID: number;
    messageType: number;
}
const router = useRouter()
const props = defineProps<Props>();
const emit = defineEmits(["doSth"]);
const state = reactive({
    show: false,
    TransferredData: undefined,
});
async function choice(val: number) {
    if (props.messageType == 1) {
        if (val == 1) {
            // 隐藏模型
            await GameObjectComponent.Default.HideAsync(props.ID);
            router.go(-1)
        } else if (val == 2) {
            state.show = false
        }
    } if (props.messageType == 2) {
        if (val == 1) {
            // 提交任务
            await WebSocketComponent.Default.PostMessageAsync(new ClientMessage.StructureAdapterRequest(MessageCode.Default.MsgCodesList.APPRAISE_SUBMIT, String(state.TransferredData)))
            //跳转评价
            router.push('strSummaryPage')

        } else if (val == 2) {
            state.show = false
        }
    }
    if (props.messageType == 3) {
        if (val == 1) {
            //退出
            WebSocketComponent.Default.PostMessage(new ClientMessage.ShutdownMessage());
        } else if (val == 2) {
            state.show = false
        }
    } if (props.messageType == 4) {
        if (val == 1) {
            // 提交任务
            WebSocketComponent.Default.PostMessageAsync(new ClientMessage.DisassemblyAdapterRequest(MessageCode.Default.MsgCodesList.APPRAISE_SUBMIT, String(state.TransferredData)))
            //跳转评价
            router.push('summaryPage')
        } else if (val == 2) {
            state.show = false
        }
    }

}
function showModel(val: any) {
    state.show = true
    if (val) {
        state.TransferredData = val
    }
}
defineExpose({ showModel })
</script>

<style scoped>
.contentBoxWp {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 9999;
}

.content {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translate(-50%);
    width: 500px;
    height: 311px;
    background-image: url('/structure/prompt_bg.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    padding: 40px;
    text-align: center;
}

.txt {
    width: 100%;
    font-size: 24px;
    font-weight: bold;
    color: #FFFFFF;
    position: absolute;
    left: 50%;
    top: 40%;
    transform: translate(-50%,-50%);
}

.txt::-webkit-scrollbar {
    display: none;
}

.Btn {
    position: absolute;
    font-size: 18px;
    text-align: center;
    color: #fff;
    font-weight: bold;
    line-height: 54px;
    width: 120px;
    height: 54px;
    background-image: url('/structure/btn_bg.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.Btn:hover {
    color: #18ECFF;
    background-image: url('/structure/btn_bg_select.png');
}

.correct {
    left: 100px;
    bottom: 40px;
}

.error {
    right: 100px;
    bottom: 40px;
}
</style>